package com.wjs.gulimall.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 导入es的相关依赖,给Spring容器中注入一个RestHighLevelClient
 */
@Configuration
public class GulimallElstaicSerchConfig {

    public static final RequestOptions COMMON_OPTIONS;
    static {
        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
//        builder.addHeader("Authorization", "Bearer " + TOKEN);
//        builder.setHttpAsyncResponseConsumerFactory(
//                new HttpAsyncResponseConsumerFactory
//                        .HeapBufferedResponseConsumerFactory(30 * 1024 * 1024 * 1024));
        COMMON_OPTIONS = builder.build();
        System.out.println("里哈哈");
    }
    @Bean
    public RestHighLevelClient esRestClient() {
        RestClientBuilder builder=RestClient.builder(new HttpHost("139.224.251.150",9200,"http"));
        RestHighLevelClient client=new RestHighLevelClient(builder);
        return client;
    }
}
